package servlet.user;


import dao.UserDao;
import entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Objects;

@WebServlet("/servlet/accountchange")
public class AccountchangeServlet extends HttpServlet{
    UserDao ud = new UserDao();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //从session中获取电话号码
//        String tel =(String) request.getSession().getAttribute("TEL");
        //通过电话查询到用户信息
//        User u = ud.loadBytel("tel");
        User u = ud.loadBytel("18270608096");
        if(Objects.isNull(u)){
            System.out.println("空");
        }
        //将用户信息传入session
        request.getSession().setAttribute("Username",u.getRealName());
        request.getSession().setAttribute("Usergender",u.getGender());
        request.getSession().setAttribute("Useraddress",u.getAddress());
        request.getSession().setAttribute("utel","18270608096");
        request.getRequestDispatcher("../UserAccount/Myaccount.vm").forward(request,response);
    }
}
